<%@ page language="java" contentType="text/html; charset=UTF-8"%>
<%-- 引入页面头 --%>
<%@ include file="/pageHead.jsp" %>

<form name="form1" id="form1" action="" method="post">
	<input type="hidden" name="errorPage" value="/systemmanage/user/v001" />
	<input type="hidden" id="id" name="id" value="${user.id}" />
	<input type="hidden" id="colUUID" name="colUUID" value="" />
 
	<div class="pageMain">
	<div class="pageTitle">
	<%=MessageResourcesUtils.getMessage(request, "systemmanage.bascsetting.title") %><span></span>
	<%=MessageResourcesUtils.getMessage(request, "systemmanage.usermaintain.title") %><span></span>
	<%=MessageResourcesUtils.getMessage(request, "systemmanage.User.update.title") %></div>
	<div class="pageBody">
 
  	<div class="form-group">
  		<ul>
  			<li>
  				<i>*</i>
  				<label><%=MessageResourcesUtils.getMessage(request, "systemmanage.User.add.usercode") %></label>
				<span><input type="text" id="userno" name="userno" value="${user.userno}" maxlength="50" size="22" class="validate[required]" /></span>
  			</li>
  			<li>
  				<i>*</i>
  				<label><%=MessageResourcesUtils.getMessage(request, "systemmanage.User.add.userloginname") %></label>
				<span><input type="text" id="loginname" name="loginname" value="${user.loginname}" maxlength="50" size="22" class="validate[required]" /></span>
  			</li>
  		</ul>
  		<ul>
  			<li>
  				<i>*</i>
  				<label><%=MessageResourcesUtils.getMessage(request, "systemmanage.User.add.username") %></label>
				<span><input type="text" id="username" name="username" value="${user.username}" maxlength="50" size="22" class="validate[required]" /></span>
  			</li>
  			<li>
  				
				
  			</li>
  		</ul>
  		<ul>
  			<li>
  				<i>*</i>
  				<label><%=MessageResourcesUtils.getMessage(request, "systemmanage.User.add.validstart") %></label>
				<span><input type="text" class="validate[required,custom[date]]" id="validstart" name="validstart" value="" /></span>
  			</li>
  			<li>
  				<i>*</i>
  				<label><%=MessageResourcesUtils.getMessage(request, "systemmanage.User.add.validend") %></label>
				<span><input type="text" class="validate[required,custom[date]]" id="validend" name="validend" value="" /></span>
  			</li>
  		</ul>
  		<ul>
  			<li>
  				<i></i>
  				<label><%=MessageResourcesUtils.getMessage(request, "systemmanage.User.add.certsn") %></label>
				<span><input type="text" id="certsn" name="certsn" value="${user.certsn}" maxlength="50" size="22" class="validate[]" /></span>
  			</li>
  			<li>
  				<i></i>
  				<label><%=MessageResourcesUtils.getMessage(request, "systemmanage.User.add.certcn") %></label>
				<span><input type="text" id="certcn" name="certcn" value="${user.certcn}" maxlength="50" size="22" class="validate[]" /></span>
  			</li>
  		</ul>
  		<ul>
  			<li>
  				<i></i>
  				<label><%=MessageResourcesUtils.getMessage(request, "systemmanage.User.add.officephone") %></label>
				<span><input type="text" id="officephone" value="${user.officephone}" name="officephone" maxlength="50" size="22" class="validate[]" /></span>
  			</li>
  			<li>
  				<i></i>
  				<label><%=MessageResourcesUtils.getMessage(request, "systemmanage.User.add.phone") %></label>
				<span><input type="text" id="phone" name="phone" value="${user.phone}" maxlength="50" size="22" class="validate[custom[phone]]" /></span>
  			</li>
  		</ul>
  		<ul>
  			<li>
  				<i>*</i>
  				<label>EMAIL</label>
				<span><input type="text" id="email" name="email" value="${user.email}" maxlength="200" size="200" class="validate[required,custom[email]]" /></span>
  			</li>
  			<li>
  			
  			</li>
  		</ul>
				</div>
				<div class="button-group">
					<input type="button" class="btn btn-default" id="butSave" name="butSave" value="<%=MessageResourcesUtils.getMessage(request, "common.button.save") %>" />
	       			<input type="button" class="btn btn-default" id="butUpdatePasw" name="butUpdatePasw" value="<%=MessageResourcesUtils.getMessage(request, "systemmanage.User.add.pwd") %>" />
	       			<input type="button" class="btn btn-default" id="butReturn" name="butReturn" value="<%=MessageResourcesUtils.getMessage(request, "common.button.back") %>" />
				</div>
	</div>
	</div>
</form>

<script type="text/javascript">	

$(document).ready(function() {

	$('#validstart').date_input();
	$('#validend').date_input();
	$('#validstart').val('${validstart}');
	$('#validend').val('${validend}');
	
	$('#butSave').click(function() {
		var exp = $('#form1').validationEngine('validate');
		var validstart = $('#validstart').val();
		var validend = $('#validend').val();
		validstart = validstart.replace(/\-/gi,"/");
		validend = validend.replace(/\-/gi,"/");
		var time1 = new Date(validstart).getTime();
		var time2 = new Date(validend).getTime();
		if(time1>=time2){
			alert("<%=MessageResourcesUtils.getMessage(request, "systemmanage.User.add.date") %>");
			return;
		}
		if(exp==true)
		{
			if(confirm('<%=MessageResourcesUtils.getMessage(request, "common.button.checksave") %>')) 
			{
				// 显示进度条
				showSending();
				$.ajax({
					type: 'POST',
				    url: '${systemctx}/systemmanage/user/validattionUser.json',
				    data: $("#form1").serialize(),
				    dataType: 'json',
				    success: function(data)
				    {
				    	//关闭执行...
						closeSending();
				    	if (data.messagetype == '2')
				    	{
				    		//显示AJAX请求后的提示信息
							$.fn.ajaxmessage(data);
				    	}
				    	else
				    	{
				    		form1.action="${systemctx}/systemmanage/user/updateUser.web";
							form1.submit();
				    	}
				    }
				});
			}
			
		}
	});
		
	$('#butReturn').click(function() {
		parent.document.location.reload();
	    $.fn.closeIssWindow();
		
	});
	
	$("#butUpdatePasw").click(function(){
		var email = $("#email").val();
		if(email == ''){
			alert('<%=MessageResourcesUtils.getMessage(request, "systemmanage.user.email.notnull")%>');
			return ;
		}
		if(confirm('<%=MessageResourcesUtils.getMessage(request, "systemmanage.user.spassword.update.confoirm")%>')){
			showSending();
			$.ajax({
				type : 'POST',
				url : '${systemctx}/systemmanage/user/sendMail.web',
				data : $("#form1").serialize(),
				dataType : 'json',
				success : function(data) {
					//关闭执行...
					closeSending();
					$.fn.ajaxmessage(data);
				}
			});
		}
	});
	
});

</SCRIPT>

<%-- 引入页面尾 --%>
<%@ include file="/pageFloor.jsp" %>